<?php
require_once ('Expression.php');

/**
 * @author wei.deng
 * @version 1.0
 * @created 05-八月-2011 11:04:55
 */
abstract class OperatorExpression extends Expression
{

	protected $l_op;
	protected $r_op;

	/**
	 * 
	 * @param l_op
	 * @param r_op
	 */
	public function __construct(Expression $l_op, Expression $r_op)
	{
		$this->l_op = $l_op;
		$this->r_op = $r_op;
	}

	/**
	 * 
	 * @param context
	 */
	public function interpret(InterpreterContext $context)
	{
		$this->l_op->interpret($context);
		$this->r_op->interpret($context);
		$result_l = $context->lookup($this->l_op);
		$result_r = $context->lookup($this->r_op);
		$this->doInterpret($context, $result_l, $result_r);
	}

	/**
	 * 
	 * @param context
	 * @param result_l
	 * @param result_r
	 */
	abstract protected function doInterpret(InterpreterContext $context, $result_l, $result_r) ;

}
?>